<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 给你一个整数数组 nums，请你将该数组升序排列。
        // 方法一
        var sortArray = function (nums) {
            for (let i = 0; i < nums.length; i++) {
                for (let j = i; j < nums.length; j++) {
                    if (nums[i] >= nums[j]) {
                        let temp = nums[i];
                        nums[i] = nums[j];
                        nums[j] = temp;
                    }
                }
            }
            return nums;
        };
        // 方法二
        var sortArray = function (nums) {
            let len = nums.length;
            for (let i = 0; i < len; i++) {
                let min = i;
                for (let j = i + 1; j < len; j++) {
                    if (nums[j] < nums[min]) {
                        min = j;
                    }
                }
                let temp = nums[i];
                nums[i] = nums[min];
                nums[min] = temp;
            }
            return nums;
        }
    </script>
</head>

<body>

</body>

</html>